package com.qn.template;

import org.springframework.util.StringUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * 工厂设计模式
 *
 * @author QuNing
 * @date 2022/08/19
 */
public class HandlerFactory {
    private static final Map<String,AbstractHandler> strategyMap = new HashMap<>();

    public static AbstractHandler getInvokeStrategy(String str) {
        return strategyMap.get(str);
    }

    public static void register(String str, AbstractHandler handler) {
        if (StringUtils.isEmpty(str) || handler == null){
            return;
        }
        strategyMap.put(str, handler);
    }

}
